package cn.thr.pethome.util;

import lombok.Data;

@Data
public class AjaxResult {

    private  String msg; //返回消息
    private  Boolean success;//成功或者失败
    private  Object data; //返回数据
    private  Long total; //总条数
     //私有构造方法
    private AjaxResult() {
    }

    private AjaxResult(String msg, Boolean success) {
        this.msg = msg;
        this.success = success;
    }

    //写成功或者失败的方法    写了static就不需要通过new 来创造对象了
    public static AjaxResult success(){
           return  new AjaxResult("成功咯",true);
    }

    public static AjaxResult error(){
        return  new AjaxResult("失败咯",false);
    }

    public AjaxResult setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public AjaxResult setSuccess(Boolean success) {
        this.success = success;
        return this;
    }

    public AjaxResult setData(Object data) {
        this.data = data;
        return this;
    }

    public AjaxResult setTotal(Long total) {
        this.total = total;
        return this;
    }





}
